package com.portal.module.userRegister.web;

import com.portal.module.userRegister.service.UserRegisterService;
import com.portal.module.userRegister.entity.UserRegister;
import com.portal.admin.base.entity.BaseAction;
import com.portal.admin.base.entity.ResultInfo;
import com.portal.admin.utils.admin.StringUtils;
import com.portal.admin.base.entity.DateUtils;
import com.portal.admin.utils.excel.ExportExcel;
import com.portal.admin.utils.excel.ImportExcel;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;

/**
*【注册信息】页面接口
*/
@RestController
@RequestMapping("/admin/userRegister")
public class UserRegisterController extends BaseAction {

    @Autowired
    private UserRegisterService userRegisterService;

    /**
    * 【注册信息】根据条件分页查询
    * @param page
    * @param userRegister
    * @return
    */
    @RequestMapping("/getPage")
    @RequiresPermissions("userRegister:getPage")
    public ResultInfo getPage(Page<UserRegister> page, UserRegister userRegister) {
        IPage<UserRegister> iPage = userRegisterService.getPage(page, userRegister);
        return ResultInfo.ok("获取分页成功", iPage);
    }

    /**
    * 【注册信息】根据条件查询
    * @param userRegister
    * @return
    */
    @RequestMapping("/getList")
    public ResultInfo getList(UserRegister userRegister) {
        List<UserRegister> list = userRegisterService.getList(userRegister);
        return ResultInfo.ok("获取列表成功", list);
    }

    /**
    * 【注册信息】根据id查询
    * @param id
    * @return
    */
    @RequestMapping("/get")
    @RequiresPermissions({"userRegister:edit","userRegister:view"})
    public ResultInfo get(String id) {
        UserRegister userRegister = userRegisterService.get(id);
        return ResultInfo.ok("获取对象成功", userRegister);
    }

    /**
    * 【注册信息】提交(新增或修改)
    * @param userRegister
    * @return
    */
    @RequestMapping("/sub")
    @RequiresPermissions("userRegister:save")
    public ResultInfo insert(UserRegister userRegister) {
        if (StringUtils.isEmpty(userRegister.getId())) { //新增
            userRegisterService.insert(userRegister);
        } else {//修改
            userRegisterService.update(userRegister);
        }
        return ResultInfo.ok("提交成功!");
    }

    /**
    * 【注册信息】删除
    * @param id
    * @return
    */
    @RequestMapping("/delete")
    @RequiresPermissions("userRegister:delete")
    public ResultInfo delete(String id) {
        userRegisterService.delete(id);
        return ResultInfo.ok("删除成功!");
    }



}



